<%@ page language="java"
         contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"
         import="com.shxt.hotel.background.Staff"
%>
<%
    request.setCharacterEncoding("UTF-8");
    String staff_name = request.getParameter("staff_name");
    String password = request.getParameter("password");
    
    Staff sta = new Staff();
    int rslt = sta.login(staff_name, password);
    
    String location = "";
    switch(rslt){
        case Staff.STAFF_NAME_ERROR:
            out.println("用户名错误");
            location = "../login.jsp";
            break;
        case Staff.PASSWORD_ERROR:
            out.println("密码错误");
            location = "../login.jsp";
            break;
        case Staff.SUCCESS:
            out.println("成功");
            location = "../background.jsp";
            break;
        default:
            break;
    }
    
    session.setAttribute("staff_id", sta.getStaffId());
    
    sta.close();
    response.sendRedirect(location);
%>